package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhHelps;
import com.ruoyi.xh.service.IXhHelpsService;

/**
 * 帮助说明Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "帮助说明Controller",value = "帮助说明Controller")
@RestController
@RequestMapping("/xh/helps")
public class XhHelpsController extends BaseController {

    @Autowired
    private IXhHelpsService xhHelpsService;

    /**
     * 查询帮助说明列表
     */
    @PreAuthorize("@ss.hasPermi('xh:helps:list')")
    @GetMapping("/list")
    @ApiOperation("查询帮助说明列表")
    public TablePageDataInfo<XhHelps> list(XhHelps xhHelps) {
        return TablePageDataInfo.success(xhHelpsService.selectXhHelpsList(xhHelps));
    }

    /**
     * 获取帮助说明详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:helps:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取帮助说明详细信息")
    public CommentResult<XhHelps> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhHelpsService.selectXhHelpsById(id));
    }

    /**
     * 新增帮助说明
     */
    @PreAuthorize("@ss.hasPermi('xh:helps:add')")
    @Log(title = "帮助说明", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增帮助说明")
    public CommentResult<XhHelps> add(@RequestBody XhHelps xhHelps) {
            xhHelpsService.insertXhHelps(xhHelps);
        return CommentResult.success();
    }

    /**
     * 修改帮助说明
     */
    @PreAuthorize("@ss.hasPermi('xh:helps:edit')")
    @Log(title = "帮助说明", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改帮助说明")
    public CommentResult<XhHelps> edit(@RequestBody XhHelps xhHelps) {
            xhHelpsService.updateXhHelps(xhHelps);
        return CommentResult.success();
    }

    /**
     * 删除帮助说明
     */
    @PreAuthorize("@ss.hasPermi('xh:helps:remove')")
    @Log(title = "帮助说明", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除帮助说明")
    public CommentResult<XhHelps> remove(@PathVariable Long[] ids) {
            xhHelpsService.deleteXhHelpsByIds(ids);
        return CommentResult.success();
    }
}
